package com.zian.manager.factory;

import cn.hutool.extra.spring.SpringUtil;
import com.zian.domain.po.SysOperLog;
import com.zian.service.ISysOperLogService;
import com.zian.utils.ip.AddressUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.TimerTask;
@Slf4j
public class AsyncFactory {

    /**
     * 操作日志记录
     *
     * @param operLog 操作日志信息
     * @return 任务task
     */
    public static TimerTask recordOper(final SysOperLog operLog)
    {
        return new TimerTask()
        {
            @Override
            public void run()
            {
                // 远程查询操作地点
                operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
                SpringUtil.getBean(ISysOperLogService.class).insertOperlog(operLog);
            }
        };
    }

}
